Step 2 - Create keyboard navigation for the Home screen

In this step you create keyboard navigation to switch between the application screens showing the recent and favorite destinations on the Home application screen. You also set focus to the button that opens the application screen which shows the sliders for adjusting the air conditioning temperature.

Set focus to elements in the Home application screen

In this section you create keyboard navigation to set focus to the button which navigates to the AirCondition application screen and to navigate to the Recent and Favorite application screens when the user presses the (Up Arrow) key on the keyboard.

To set focus to elements in the Home application screen:

  1. In the Project > RootPage > NavigationButtons select the HomeButton node, in the Properties add the Up Navigation Node property, and set it to #ACButton.
    You set the application to set focus to the ACButton node when the HomeButton has focus and the user presses the (Up Arrow) key on the keyboard. When the ACButton node has focus, the user can use the Enter key on the keyboard to navigate to the AirCondition screen.
  2. In the Project > RootPage > Home > HomeControls select the ACButton node, in the Node Components > Triggers section add to the Button: Click trigger a Set Focus action, and set the Target Item to #DriverButton.
    You set focus to the DriverButton node when the user presses the ACButton to navigate to the AirCondition screen.
  3. In the Project > RootPage > Home > HomeControls select the RecentFavoriteNavigation node, in the Properties right-click, select Add Property > Focus Manager > Focus Scope property, and enable that property.
    You use the Focus Scope property to forward the focus from the RecentFavoriteNavigation node to the RecentButton node to allow navigation between the Recent and Favorite application screens. This way the user can use keyboard keys to navigate between those toggle buttons.
  4. In the Project > RootPage > Home > HomeControls > RecentFavoriteNavigation select the RecentButton node, in the Properties right-click, select Add Property > Node > Logical Focus property, and enable that property.
    You set the RecentButton node to receive focus when you set focus to the Toggle Button Group 2D node RecentFavoriteNavigation.
  5. In the Project > RootPage > Home > HomeControls select the ACButton node, in the Properties add the Up Navigation Node property, and set it to #RecentFavoriteNavigation.
    You set focus to the RecentFavoriteNavigation node when the user presses the (Up Arrow) key on the keyboard. The RecentFavoriteNavigation forwards the focus to the RecentButton node if the Page node Recent is active, and to the FavoriteButton node if the Page node Favorite is active.
  6. In the Project select the Home > HomeControls > RecentFavoriteNavigation > RecentButton node and in the Node Components > Triggers section add an On Property Change trigger.
    You use the On Property Change trigger to set off actions in that trigger when the value of the Focused property of the RecentButton node changes.
  7. In the Node Components in the On Property Change trigger click Trigger Settings to open the Trigger Settings Editor and set the Property Type to Node.Focused.
    You set the On Property Change trigger to keep track of when the value of the Focused property of the RecentButton node changes.
  8. Add to the On Property Change trigger an Execute Script action and use the ButtonState.js script.
    When the RecentButton toggle button receives focus, the On Property Change trigger sets off the Execute Script action which toggles on that toggle button.

  9. In the Node Components in the Toggle Button: Toggled On trigger add a Go to State action and in the action set:

    The Page node Recent uses a state manager which sets the appearance of that node when that page is active. You set the Recent node to change its appearance when the RecentButton receives focus.

  10. In the On Property Change trigger click Add new trigger for On Property Change to add another On Property Change trigger and in the Trigger Settings set the Property Type to Node.Focused.
    You use this On Property Change trigger to change the appearance of the Page node Recent when the RecentButton is not focused.
  11. In the Trigger Settings Editor click Add condition to add a condition to the On Property Change trigger and in the Trigger Condition Editor set:
  12. In the Node Components in the On Property Change trigger you created add a Go to State action and in the action set:

    You set the Recent node to change its appearance when the RecentButton is not focused.

In the Preview when you press the (Up Arrow) key on the keyboard when the Home application screen is active, you:

In the Preview when the ACButton is focused, press the Enter key on the keyboard to navigate to the AirCondition application screen.

Set a keyboard key to focus the navigation bar

In this section you add the functionality to move the focus from the content of the Home application screen to the navigation bar.

To use keyboard keys to set focus to the navigation bar:

  1. In the Project > RootPage > Home > HomeControls select the ACButton node, in the Properties add the Down Navigation Node property, and set it to #HomeButton.
    The application sets focus from the ACButton node to the HomeButton node on the navigation bar when the user presses the (Down Arrow) key on the keyboard.
  2. Repeat the previous step for the Home > HomeControls > RecentFavoriteNavigation > RecentButton and FavoriteButton nodes but for those nodes set the Down Navigation Node property to #ACButton.

In the Preview when you press the (Down Arrow) key on the keyboard when the Recent or Favorite screen has focus, you:

Create keyboard navigation between the Recent and Favorite application screens

In this section you set the application to navigate between the Recent and Favorite application screens when the user presses a key on the keyboard.

To create keyboard navigation between the Recent and Favorite application screens:

  1. In the Project select the RecentButton node, in the Node Components right-click the On Property Change trigger, and select Copy to copy that trigger.
    You use the same trigger in the FavoriteButton node.
  2. In the Project select the FavoriteButton node and in the Node Components right-click and select Paste Trigger to paste the On Property Change trigger to that node.
  3. In the Project select the FavoriteButton node and in the Node Components above the second On Property Change trigger click Trigger Settings, in the Trigger Settings Editor click the condition you created for the RecentButton node, and in the Trigger Condition Editor set the Item to #FavoriteButton.
  4. In the Node Components in the second On Property Change trigger click the Go to State action, and in that action set:
  5. In the Node Components in the Toggle Button: Toggled On trigger add a Go to State action and in the action set:

    You set the Favorite node to change its appearance when the FavoriteButton receives focus.

  6. In the Project select the RecentButton node, in the Properties add the Right Navigation Node property, and set it to #FavoriteButton.
    You set the application to set the focus from the RecentButton node to the FavoriteButton node when the user presses the (Right Arrow) key on the keyboard.
  7. In the Project select the FavoriteButton node, in the Properties add the Left Navigation Node property, and set it to #RecentButton.
    You set the application to set the focus from the FavoriteButton node to the RecentButton node when the user presses the (Left Arrow) key on the keyboard.

In the Preview when the Recent or Favorite application screen has focus, use the (Right Arrow) and (Left Arrow) keyboard keys to navigate between those screens.

Set a key to close the air conditioning settings

In this section you set the AirCondition screen to close when the user presses the E keyboard key.

To set a key to close the air conditioning settings:

  1. In the Project > RootPage > Home > AirCondition > AirConditionControls > Toggle Button Group 2D select the DriverButton node and in the Node Components in the Triggers section add a Key Down trigger.
    You use the Key Down trigger to set off an action which sets focus to a node when the user presses a specific key on the keyboard.
  2. In the Trigger Settings for the trigger you created in the previous step click Add condition and in the Trigger Condition Editor set:
  3. Add to the Key Down trigger the actions you need to close the AirCondition application screen:
  4. In the Project select the DriverButton node, in the Node Components right-click the Key Down trigger, and select Copy.
    You use the same trigger for the Passenger node and the Slider 2D nodes to close the AirCondition application screen when the user presses the E key.
  5. In the Project select the PassengerButton node, in the Node Components right-click, and select Paste Trigger.
  6. Repeat the previous step for the Home > AirCondition > Driver > Slider 2D and Home > AirCondition > Passenger > Slider 2D nodes to paste the Key Down trigger to those nodes.
  7. In the Project > Home > AirCondition > AirConditionControls select the Close node, in the Node Components add to the Button: Click trigger a Set Focus action, and set the Target Item to #HomeButton.
    You set focus back to the HomeButton toggle button when the user uses the pointer to close the AirCondition application screen.

In the Preview in the AirCondition application screen press the E key on the keyboard to close that screen.

Use these keyboard keys to navigate the application:



< PREVIOUS STEP
NEXT STEP >

To find out more about how focus works in Kanzi, see Focus.

To find out more about the Page and Page Host nodes, see Using the Page and Page Host nodes.

To find out more about using triggers, see Using triggers.

To find out more about using JavaScript scripts, see Using scripts.